package com.training1.core.modules.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.training1.core.dto.TreeNodeDto;
import com.training1.core.tree.misc.TreeLayoutDefinition;

@Service
public class NodeService {

	
	/**
	 * 
	 * @param areaId
	 * @param type
	 * @return
	 */
	@Transactional(readOnly=true)
	public List<TreeNodeDto> listByTypeAndTreeIndex(int areaId,char type) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", areaId);
		
		List<TreeNodeDto> treeNodes = null ;
//		if(type=='A'){
//			treeNodes= aAreaDao.listByTypeAndTreeIndex(params);
//		}else{
//			treeNodes= bAreaDao.listByTypeAndTreeIndex(params);
//		}
		for(TreeNodeDto node : treeNodes){
			node.setLevel(TreeLayoutDefinition.getLevelIndex(node.getViewIndex()));
		}
		return treeNodes;
	}

}
